package com.usian.util.work;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.usian.util.ConnectionUtil;

public class Send {
    public static void main(String[] args) throws Exception {
        // 获取到连接
        Connection connection = ConnectionUtil.getConnection();
        // 获取通道
        Channel channel = connection.createChannel();
        // 声明队列
        channel.queueDeclare("rabbitmq-work_queue", false, false, false, null);
        // 循环发布任务
        for (int i = 0; i < 50; i++) {
            // 消息内容
            String message = "rabbitmq-work_queue" + i;
            channel.basicPublish("", "rabbitmq-work_queue", null, message.getBytes());
            System.out.println(message + "'");


        }
        // 关闭通道和连接
        channel.close();
        connection.close();
    }

}
